tg-me.com/python_codes/188
Create:
Last Update:
Last Update:
#Basics
Checking if two words are anagrams
Code:
from collections import Counter
def is_anagram(str1, str2):
return Counter(str1) == Counter(str2)
# or without having to import anything
def is_anagram(str1, str2):
return sorted(str1) == sorted(str2)
print(is_anagram('code', 'doce'))
print(is_anagram('python', 'yton'))
Output:
True
False
Share and Support
@Python_Codes
BY Python Codes
Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283
Share with your friend now:
tg-me.com/python_codes/188